#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include "cJSON.h"

struct student
{
	int id;
	char name[10];
	int age;
};

int main()
{
	struct student stu;
	memset(&stu,0,sizeof(stu));

	printf("please input infomation:\n");
	scanf("%d%s%d",&stu.id,stu.name,&stu.age);

	cJSON *json = NULL;

	json = cJSON_CreateObject();

	cJSON_AddItemToObject(json,"id",cJSON_CreateNumber(stu.id));
	cJSON_AddItemToObject(json,"name",cJSON_CreateString(stu.name));
	cJSON_AddItemToObject(json,"age",cJSON_CreateNumber(stu.age));

	char *dest = NULL;

	dest = cJSON_Print(json);

	puts(dest);

	free(dest);

	cJSON_Delete(json);

	return 0;

}
